﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NEWS;

public partial class admin_menu_edit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = Request.QueryString["id"].Trim();
            NEWS.Model.Menu menu = NEWS.BLL.Menu.GetMenu(int.Parse(id));

            this.id.Value = id;
            this.title.Text = menu.Title;
            this.state.Text = menu.State.ToString();
        }

             
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        NEWS.Model.Menu menu = new NEWS.Model.Menu();

        menu.Id = int.Parse(this.id.Value);
        menu.State = int.Parse(this.state.Text);
        menu.Title = this.title.Text;

        if (NEWS.BLL.Menu.update(menu))
        {
            NEWS.JsHelper.AlertAndRedirect("编辑成功！", "menu_list.aspx");
        }
        else
        {
            NEWS.JsHelper.AlertAndRedirect("编辑失败！", "menu_edit.aspx");
        }
    }
}